package com.lpf.mediator;

// 客户端代码
public class MediatorPatternDemo {
    public static void main(String[] args) {
        // 创建中介者 - 聊天室
        ChatMediator chatRoom = new ChatRoom();

        // 创建用户
        User alice = new ConcreteUser(chatRoom, "Alice");
        User bob = new ConcreteUser(chatRoom, "Bob");
        User charlie = new ConcreteUser(chatRoom, "Charlie");

        // 添加用户到聊天室
        chatRoom.addUser(alice);
        chatRoom.addUser(bob);
        chatRoom.addUser(charlie);

        // 用户发送消息
        alice.send("Hello, everyone!");
        bob.send("Hi, Alice!");
        charlie.send("Hey, what's up?");
    }
}